# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=astunparse
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.6.3
pkgrel=1
pkgdesc='An AST unparser for Python (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/simonpercivall/astunparse"
license=('python')
depends=("${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-python-wheel")
source=("${_realname}-$pkgver.tar.gz::https://github.com/simonpercivall/astunparse/archive/v$pkgver.tar.gz")
sha512sums=('8f85d848c65d1728df767b1c2aee44aa4ce79a6810c348a5b3669b56f4bc5ce7f09414557be38d0a5103a77872d75083762bd2829d02ac8414df17221d30492b')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
